#include "yslabel.h"

#include <mainwindow.h>



YSLabel::YSLabel(QWidget *parent):
    QLabel(parent)
{

}

YSLabel::YSLabel(const QString &text, QWidget *parent, Qt::WindowFlags f):
    QLabel(parent,f)
{
    setText(text);
}

void YSLabel::showEvent(QShowEvent *event)
{
    Q_UNUSED(event)
    if(m_bFirst)
    {
        m_bFirst=false;
        // 计算新的按钮大小
        int newWidth = static_cast<int>(width() * g_xScale);
        int newHeight = static_cast<int>(height() * g_xScale);
        // 设置按钮的大小
        setFixedSize(newWidth, newHeight);
        // 设置按钮的字号
        QFont font = this->font();
        font.setPixelSize(20 * g_xScale);
        font.setFamily("微软雅黑");
        setFont(font);
    }
}
